import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SlideshowVO, SlideshowForm, SlideshowQuery } from '@/api/system/slideshow/types';

/**
 * 查询轮播图列表
 * @param query
 * @returns {*}
 */

export const listSlideshow = (query?: SlideshowQuery): AxiosPromise<SlideshowVO[]> => {
  return request({
    url: '/system/slideshow/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询轮播图详细
 * @param id
 */
export const getSlideshow = (id: string | number): AxiosPromise<SlideshowVO> => {
  return request({
    url: '/system/slideshow/' + id,
    method: 'get'
  });
};

/**
 * 新增轮播图
 * @param data
 */
export const addSlideshow = (data: SlideshowForm) => {
  return request({
    url: '/system/slideshow',
    method: 'post',
    data: data
  });
};

/**
 * 修改轮播图
 * @param data
 */
export const updateSlideshow = (data: SlideshowForm) => {
  return request({
    url: '/system/slideshow',
    method: 'put',
    data: data
  });
};

/**
 * 删除轮播图
 * @param id
 */
export const delSlideshow = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/slideshow/' + id,
    method: 'delete'
  });
};
